ARD2  1.00 for Rev B. Hardware
Airbag Reference Demonstrator using MPC5604P
CG147.h File Reference

Bosch's CG147 driver using proprietary mail scheduler and MPC5604P. More...

Go to the source code of this file.

Defines

#define TRUE   (1u)
#define CLEAR   (0u)
#define BITS_IN_NIBBLE   (4u)
#define BITS_IN_16   (16u)
#define BITS_IN_BYTE   (8u)
#define BYTES_IN_16   (2u)
#define BYTES_IN_32   (4u)
#define BIT_DEFINITION
#define BIT0   (1u << 0u)
#define BIT1   (1u << 1u)
#define BIT2   (1u << 2u)
#define BIT3   (1u << 3u)
#define BIT4   (1u << 4u)
#define BIT5   (1u << 5u)
#define BIT6   (1u << 6u)
#define BIT7   (1u << 7u)
#define BIT8   (1u << 8u)
#define BIT9   (1u << 9u)
#define BIT10   (1u << 10)
#define BIT11   (1u << 11)
#define BIT12   (1u << 12)
#define BIT13   (1u << 13)
#define BIT14   (1u << 14)
#define BIT15   (1u << 15)
#define BIT16   (1u << 16)
#define BIT17   (1u << 17)
#define BIT18   (1u << 18)
#define BIT19   (1u << 19)
#define BIT20   (1u << 20)
#define BIT21   (1u << 21)
#define BIT22   (1u << 22)
#define BIT23   (1u << 23)
#define BIT24   (1u << 24)
#define BIT25   (1u << 25)
#define BIT26   (1u << 26)
#define BIT27   (1u << 27)
#define BIT28   (1u << 28)
#define BIT29   (1u << 29)
#define BIT30   (1u << 30)
#define BIT31   (1u << 31)
#define CG147_TRANSFER_FAILURE_FLAG   ((uint16_t)BIT15)
#define CG147_TEST_ACTIVE_FLAG   ((uint16_t)BIT14)
#define CG147_END_OF_PROGRAMMING_FLAG   ((uint16_t)BIT13)
#define CG147_AD_BUSY_FLAG   ((uint16_t)BIT11)
#define CG147_WATCHDOG_FAULT_FLAG   ((uint16_t)BIT10)
#define CG147_DISPOSAL_FLAG_1   ((uint16_t)BIT9)
#define CG147_DISPOSAL_FLAG_2   ((uint16_t)BIT8)
#define CG147_N_ADC_DATA   ((uint16_t)20)
#define CG147_SAFETY_ID2   ((uint16_t)BIT12)
#define CG147_SAFETY_ID1   ((uint16_t)BIT11)
#define CG147_SAFETY_ID0   ((uint16_t)BIT10)
#define SBC_READ_DEV_ID   ((uint8_t)0x01u)
#define SBC_READ_REV_ID   ((uint8_t)0x07u)
#define SBC_READ_MON_ID   ((uint8_t)0x02u)
#define SBC_WD2_TRIGGER   ((uint8_t)0x08u)
#define SBC_WD3_TRIGGER   ((uint8_t)0x0Bu)
#define SBC_READ_WD_STATUS   ((uint8_t)0x04u)
#define SBC_READ_WD_FC   ((uint8_t)0x0Eu)
#define SBC_EOP   ((uint8_t)0x0Du)
#define SBC_PSI_SUPPLY   ((uint8_t)0x10u)
#define SBC_FLM_STATUS   ((uint8_t)0x13u)
#define SBC_END_ENABLE   ((uint8_t)0x15u)
#define SBC_SET_I_AIO   ((uint8_t)0x16u)
#define SBC_READ_THRES   ((uint8_t)0x19u)
#define SBC_SET_I_LIN   ((uint8_t)0x1Au)
#define SBC_START_ADC   ((uint8_t)0x1Cu)
#define SBC_READ_ADC   ((uint8_t)0x1Fu)
#define SBC_TEST_ANA_HEAD   ((uint8_t)0x20u)
#define SBC_POWER_CTRL   ((uint8_t)0x23u)
#define SBC_POWER_STATUS   ((uint8_t)0x25u)
#define SBC_AOUT_CTRL   ((uint8_t)0x26u)
#define SBC_HS_ON1_4   ((uint8_t)0x29u)
#define SBC_HS_ON5_8   ((uint8_t)0x2Au)
#define SBC_HS_ON9_12   ((uint8_t)0x2Cu)
#define SBC_FLM_TEST_SRC   ((uint8_t)0x2Fu)
#define SBC_LS_ON1_4   ((uint8_t)0x31u)
#define SBC_LS_ON5_8   ((uint8_t)0x32u)
#define SBC_LS_ON9_12   ((uint8_t)0x34u)
#define SBC_FLM_TEST_SINK   ((uint8_t)0x37u)
#define SBC_FLM_LOCK   ((uint8_t)0x3Bu)
#define SBC_LOWLEAK   ((uint8_t)0x3Du)
#define SBC_FIRE_COUNTER   ((uint8_t)0x3Eu)
#define SBC_READ_PSI   ((uint8_t)0x80u)
#define SBC_SELECT_PSI   ((uint8_t)0xC2u)
#define SBC_DISPOSAL   ((uint8_t)0xC4u)
#define SBC_SET_AIO_PWM   ((uint8_t)0xFEu)
#define SBC_DEMAND_TEST   ((uint8_t)0x38u)
#define SBC_THRES_TEST_DATA   ((uint8_t)0xC8u)
#define SBC_THRES_TEST_SID   ((uint8_t)0xCBu)
#define SBC_ENABLE_PROG   ((uint8_t)0xCDu)
#define SBC_SET_MM5_MODE   ((uint8_t)0xCEu)
#define SBC_PSI_SYNC_GEN   ((uint8_t)0xF2u)
#define SBC_PSI_SYNC_MASK   ((uint8_t)0xF4u)
#define SBC_AIO_STATUS   ((uint8_t)0xF8u)
#define SBC_SET_PSI_IPP   ((uint8_t)0xDAu)
#define SBC_READ_PSI_IPP   ((uint8_t)0xD3u)
#define SBC_PSI_IQ_STATUS   ((uint8_t)0xD5u)
#define SBC_CLEAR_FIRE_CNT   ((uint8_t)0xD6u)
#define SBC_SID_EVALUATE   ((uint8_t)0xD9u)
#define SBC_TEST_PSI_CONS   ((uint8_t)0xDCu)
#define SBC_PROG_GENERAL   ((uint8_t)0x40u)
#define SBC_PROG_UP_THRES   ((uint8_t)0x43u)
#define SBC_PROG_LOW_THRES   ((uint8_t)0x45u)
#define SBC_PROG_AIN1_2   ((uint8_t)0x49u)
#define SBC_PROG_AIN3_4   ((uint8_t)0x4Au)
#define SBC_PROG_AIN5_6   ((uint8_t)0x4Cu)
#define SBC_PROG_AIO_WL   ((uint8_t)0x79u)
#define SBC_PROG_PSI1_LINE   ((uint8_t)0x4Fu)
#define SBC_PROG_PSI2_LINE   ((uint8_t)0x51u)
#define SBC_PROG_PSI3_LINE   ((uint8_t)0x52u)
#define SBC_PROG_PSI4_LINE   ((uint8_t)0x54u)
#define SBC_PROG_UFS_THRES   ((uint8_t)0x57u)
#define SBC_PROG_PAS_THRES   ((uint8_t)0x58u)
#define SBC_PROG_PRES_THRES   ((uint8_t)0x5Bu)
#define SBC_PROG_ROLL_THRES   ((uint8_t)0x5Du)
#define SBC_PROG_X_THRES   ((uint8_t)0x5Eu)
#define SBC_PROG_Y_THRES   ((uint8_t)0x61u)
#define SBC_PROG_POWER   ((uint8_t)0x62u)
#define SBC_PROG_FLM_ENH   ((uint8_t)0x64u)
#define SBC_PROG_SDIS1_4   ((uint8_t)0x67u)
#define SBC_PROG_SDIS5_8   ((uint8_t)0x68u)
#define SBC_PROG_SDIS9_12   ((uint8_t)0x6Bu)
#define SBC_PROG_DISXY1_4   ((uint8_t)0x6Du)
#define SBC_PROG_DISXY5_8   ((uint8_t)0x6Eu)
#define SBC_PROG_DISXY9_12   ((uint8_t)0x70u)
#define SBC_PROG_FLM_CONF   ((uint8_t)0x73u)
#define SBC_PROG_PSYNC_MODE   ((uint8_t)0x75u)
#define SBC_PROG_SDIS_CH   ((uint8_t)0x7Au)
#define SBC_PROG_PSI_SID   ((uint8_t)0x76u)
#define SBC_PROG_MM5_SID   ((uint8_t)0x7Fu)
#define SBC_PROG_ENH_SAFETY   ((uint8_t)0x46u)
#define SBC_AOUT_VSTT33_DIV_2   ((uint8_t)0x00u)
#define SBC_AOUT_VSTT50_DIV_2   ((uint8_t)0x01u)
#define SBC_AOUT_TEMP_DIODE   ((uint8_t)0x02u)
#define SBC_AOUT_VAS_SET   ((uint8_t)0x03u)
#define SBC_AOUT_AGND   ((uint8_t)0x04u)
#define SBC_AOUT_SQREF   ((uint8_t)0x05u)
#define SBC_AOUT_AVST33   ((uint8_t)0x06u)
#define SBC_AOUT_VSYNC_DIV_8   ((uint8_t)0x07u)
#define SBC_AOUT_PSI1_DIV_6   ((uint8_t)0x08u)
#define SBC_AOUT_PSI2_DIV_6   ((uint8_t)0x09u)
#define SBC_AOUT_PSI3_DIV_6   ((uint8_t)0x0Au)
#define SBC_AOUT_PSI4_DIV_6   ((uint8_t)0x0Bu)
#define SBC_AOUT_VDN_DIV_146   ((uint8_t)0x0Du)
#define SBC_AOUT_IGH1   ((uint8_t)0x10u)
#define SBC_AOUT_IGH2   ((uint8_t)0x11u)
#define SBC_AOUT_IGH3   ((uint8_t)0x12u)
#define SBC_AOUT_IGH4   ((uint8_t)0x13u)
#define SBC_AOUT_IGL1   ((uint8_t)0x14u)
#define SBC_AOUT_IGL2   ((uint8_t)0x15u)
#define SBC_AOUT_IGL3   ((uint8_t)0x16u)
#define SBC_AOUT_IGL4   ((uint8_t)0x17u)
#define SBC_AOUT_ER1_DIV_10   ((uint8_t)0x18u)
#define SBC_AOUT_ER2_DIV_10   ((uint8_t)0x19u)
#define SBC_AOUT_IGH5   ((uint8_t)0x20u)
#define SBC_AOUT_IGH6   ((uint8_t)0x21u)
#define SBC_AOUT_IGH7   ((uint8_t)0x22u)
#define SBC_AOUT_IGH8   ((uint8_t)0x23u)
#define SBC_AOUT_IGL5   ((uint8_t)0x24u)
#define SBC_AOUT_IGL6   ((uint8_t)0x25u)
#define SBC_AOUT_IGL7   ((uint8_t)0x26u)
#define SBC_AOUT_IGL8   ((uint8_t)0x27u)
#define SBC_AOUT_ER3_DIV_10   ((uint8_t)0x28u)
#define SBC_AOUT_ER4_DIV_10   ((uint8_t)0x29u)
#define SBC_AOUT_IGH9   ((uint8_t)0x30u)
#define SBC_AOUT_IGH10   ((uint8_t)0x31u)
#define SBC_AOUT_IGH11   ((uint8_t)0x32u)
#define SBC_AOUT_IGH12   ((uint8_t)0x33u)
#define SBC_AOUT_IGL9   ((uint8_t)0x34u)
#define SBC_AOUT_IGL10   ((uint8_t)0x35u)
#define SBC_AOUT_IGL11   ((uint8_t)0x36u)
#define SBC_AOUT_IGL12   ((uint8_t)0x37u)
#define SBC_AOUT_ER5_DIV_10   ((uint8_t)0x38u)
#define SBC_AOUT_ER6_DIV_10   ((uint8_t)0x39u)
#define SBC_WD_CHECKWORD_1   ((uint8_t)0x20)
#define SBC_WD_CHECKWORD_2   ((uint8_t)0xFD)
#define SBC_WD_CHECKWORD_3   ((uint8_t)0x8A)
#define SBC_WD_CHECKWORD_4   ((uint8_t)0x57)
#define SBC_WD_CHECKWORD_5   ((uint8_t)0xEC)
#define SBC_WD_CHECKWORD_6   ((uint8_t)0x31)
#define SBC_WD_CHECKWORD_7   ((uint8_t)0x46)
#define SBC_WD_CHECKWORD_8   ((uint8_t)0x9B)
#define SBC_WD_RESPONSE_1   ((uint8_t)0x19)
#define SBC_WD_RESPONSE_2   ((uint8_t)0x6E)
#define SBC_WD_RESPONSE_3   ((uint8_t)0xB3)
#define SBC_WD_RESPONSE_4   ((uint8_t)0xC4)
#define SBC_WD_RESPONSE_5   ((uint8_t)0x2A)
#define SBC_WD_RESPONSE_6   ((uint8_t)0x5D)
#define SBC_WD_RESPONSE_7   ((uint8_t)0x80)
#define SBC_WD_RESPONSE_8   ((uint8_t)0xF7)
#define CG147_TRANSCIEVE_ERROR   ((uint8_t)0x80u)
#define CG147_PIT_CONFIG_ERROR   ((uint8_t)0x40u)
#define CG147_RESPONSE_PARITY_FAILURE   ((uint8_t)0x01u)
#define CG147_INPUT_BUFFER_SIZE   ((uint8_t)30u)
#define CG147_RESPONSE_STATUS_BYTE_MASK   (0xFFu)
#define CG147_ACCEL_STATUS_BYTE_MASK   (0xE0u)
#define CG147_ACCEL_READING_MASK   (0x03u)
#define CG147_UNLOCK_HS_LS   (0x05u)
#define CG147_ALL_AIRBAG_MASK   (0xFFFu)
#define CG147_SQUIB_FIRE_OFFSET   (1u)
#define CG147_TEST_CMD_SIZE_FIRST_PART   (2u)
#define CG147_TEST_CMD_SIZE_SECOND_PART
#define CG147_TEST_IS_VER_ESR   (0x03u)
#define CG147_TEST_IS_VER_CAP   (0x05u)
#define CG147_TEST_IS_POL_PROT   (0x09u)
#define SBC_AINADC_VAS_SET   ((uint8_t)0x10u)
#define SBC_AINADC_REF_BG   ((uint8_t)0x11u)
#define SBC_AINADC_REF_BG2   ((uint8_t)0x12u)
#define SBC_AINADC_23REF_BG2   ((uint8_t)0x13u)
#define SBC_AINADC_AGND   ((uint8_t)0x14u)
#define SBC_AINMUX_NO_SWITCHES   ((uint8_t)0x0Fu)
#define SBC_AINMUX_VOLT   (0x0Fu)
#define SBC_AINMUX_AIN1   (0x00u)
#define SBC_AINMUX_AIN2   (0x01u)
#define SBC_AINMUX_AIN3   (0x02u)
#define SBC_AINMUX_AIN4   (0x03u)
#define SBC_AINMUX_AIN5   (0x04u)
#define SBC_AINMUX_AIN6   (0x05u)
#define SBC_AINMUX_AIO1   (0x06u)
#define SBC_AINMUX_AIO2   (0x07u)
#define CG147_N_ER_LINES   (6u)
#define CG147_DEFAULT_POWER_STG   0x10u
#define CG147_SPI_FAKE_TIME_20US   (uint16_t)((20/(3.93)) + 1u)
#define CG147_SPI_FAKE_TIME_50US   (uint16_t)((50/(3.93)) + 1u)
#define CG147_TIME_DIVIDER   (500000)
#define CG147_PULSE_DELAY_40_USEC
#define CG147_PULSE_DELAY_20_USEC
#define CG147_WD2_COUNT_FOR_ISR   ((uint16_t)SCHED_500US_PERIOD)
#define CG147_WD3_COUNT_FOR_ISR   ((uint8_t)180u)
#define SIGN_10_BITS   ((uint16_t)BIT9)
#define MAX_VALUE_10_BITS   ((uint16_t)0x3FFu)
#define CG147_SAT_MASK_MAX   ((uint16_t)BIT12)
#define CG147_SAT_MASK_MIN   ((uint16_t)BIT0)
#define CG147_LONG_TEST_WAIT_MS   ((uint16_t)187u)
#define N_ELEMENTS(X)   (sizeof(X)/sizeof(*(X)))
#define CG147_AIRBAG_MASK(XX)   XX

Functions

void vfnCG147Init (const uint8_t cu8DSPIMainInstance, const uint8_t cu8ChipSelect, const uint8_t cu8DSPISecondaryInstance1, const uint8_t cu8DSPISecondaryInstance2, const uint8_t cu8NSysResPort, const uint8_t cu8NSysResPin)
 Initializes the SBC based on pre-configured table.
void vfnCG147ToggleResetPin (const uint8_t cu8State, const uint8_t cu8NSysResPort, const uint8_t cu8NSysResPin)
 Sets a logical level on the SBC's reset pin.
uint8_t u8fnCG147ReadAOut (const uint8_t cu8DSPIInstance, const uint8_t cu8ChipSelect, const uint8_t cu8ADCInstance, const uint8_t cu8ADCCh, const uint8_t cu8CG147Ch, uint16_t *pu16Result)
 Configures CG147 for a particular AOUT value, configures the MCU for reading this channel and launches a "normal" acquisition.
uint8_t u8fnCG147ReadPSI5Accel (const uint8_t cu8DSPIInstance, const uint8_t cu8ChipSelect, uint16_t *pu16Accel)
 Asks the SBC for PSI acceleration values. This fn. automatically converts signed data into unsigned data.
uint8_t u8fnCG147ReadPSI5RegSensor (const uint8_t cu8DSPIInstance, const uint8_t cu8ChipSelect, uint16_t *pu16Accel)
 Asks the SBC for PSI acceleration values. This fn does not convert signed data into unsigned data.
vuint8_t u8fnCG147Transcieve (uint8_t u8Cmd, uint8_t u8Value, uint8_t u8SPIInstance, uint8_t u8CSToCG147)
 Sends a 7-bit command with an 8-bit argument to a CG147 SBC using SPI. Command parity should be pre-calculated. Response is placed in global variable gau16CG147Responses.
uint8_t u8fnCG147BatchTranscieve (uint8_t *pu8Cmd, uint8_t *pu8Value, uint8_t u8SPIInstance, uint8_t u8CSToCG147, uint8_t u8NOfMessages)
 Sends a series of 7-bit commands with an 8-bit arguments to a CG147 SBC using SPI. Command parity should be pre-calculated. Response is placed in global variable gau16CG147Responses.
uint8_t u8fnCG147ScheduleAOut (const uint8_t cu8DSPIInstance, const uint8_t cu8ChipSelect, const uint8_t cu8CG147Ch, uint16_t *pu16Status, uint32_t *pu32Time)
 Schedules a CG147 configuration for a particular AOUT value. This function assumes that the ADC is always running and that the correct pin connected to AOut has been scheduled for reading.
uint8_t u8fnCG147SchedulePSI5Accel (const uint8_t cu8DSPIInstance, const uint8_t cu8ChipSelect, uint16_t *pu16Accel, uint32_t *pu32Time)
 Schedules a request for PSI acceleration values. This fn does not convert signed data into unsigned data.
uint8_t u8fnCG147ScheduleTransfer (uint8_t u8SPIInstance, uint8_t u8CSToCG147, uint8_t u8Cmd, uint8_t u8Value, uint16_t *pu16Response, uint32_t *pu32RequestTime)
 Schedules a 7-bit command with an 8-bit argument to a CG147 SBC using SPI & the scheduler. Command parity should be pre-calculated.
uint8_t u8fnCG147ScheduleBatchTransfer (uint8_t u8SPIInstance, uint8_t u8CSToCG147, uint8_t *pu8Cmd, uint8_t *pu8Value, uint16_t *pu16Response, uint8_t u8Size, uint32_t *pu32RequestTime)
 Schedules a series of 7-bit commands with an 8-bit arguments to a CG147 SBC using SPI. Command parity should be pre-calculated.
uint8_t u8fnCG147ScheduleSafeAOut (const uint8_t cu8DSPIInstance1, const uint8_t cu8DSPIInstance2, const uint8_t cu8ChipSelect, const uint8_t cu8CG147Ch, uint32_t *pu32Status, uint32_t *pu32Time)
 Schedules a CG147 configuration for a particular AOUT value. Assumes configuration for ADC on micro's side is set.
uint8_t u8fnCG147ScheduleSafePSI5Accel (const uint8_t cu8DSPIInstance1, const uint8_t cu8DSPIInstance2, const uint8_t cu8ChipSelect, const uint16_t cu16ActiveChannels, uint32_t *pu32RawAccel, uint32_t *pu32Time)
 Schedules a request for PSI acceleration values. This fn does not convert signed data into unsigned data.
uint8_t u8fnCG147ScheduleSafeSquibFireStart (const uint8_t cu8DSPIInstance1, const uint8_t cu8DSPIInstance2, const uint8_t cu8ChipSelect, uint16_t u16ChannelMask, uint32_t *pu32Time)
 This fn. shall be called when the decision to deploy an airbag has been taken. It will bring FL_EN high, enable the high-side and low-side switches.
uint8_t u8fnCG147ScheduleSafeSquibFireStop (const uint8_t cu8DSPIInstance1, const uint8_t cu8DSPIInstance2, const uint8_t cu8ChipSelect, uint32_t *pu32Time)
 This fn. shall be called after an airbag has been deployed to disable low-side and high-side drivers.
uint8_t u8fnCG147ScheduleSafeTest (const uint8_t cu8DSPIInstance1, const uint8_t cu8DSPIInstance2, const uint8_t cu8ChipSelect, uint8_t u8TestCase, uint32_t *pu32Result, uint16_t *pu16ADCResponses, uint32_t *pu32Time)
 This fn. is meant to execute one of the three capacitor tests described in the CG147 spec using cau8CG147TestCmds as commands. It is called by upper-layer routines as required. Final result is not the status of the test.
uint8_t u8fnCG147ScheduleSafeTransfer (const uint8_t cu8SPIInstance1, const uint8_t cu8SPIInstance2, const uint8_t cu8CSToCG147, uint8_t u8Cmd, uint8_t u8Value, uint16_t *pu16Response, uint32_t *pu32RequestTime)
 Schedules ONE 17-bit command transfers where the command is 7-bits long with a pre-calculated parity bit, arguments for the command are 8-bit long, and an extra parity bit for the complete message is added. This function requires the use of scheduled transfers.
uint8_t u8fnCG147ScheduleSafeBatchTransfer (const uint8_t cu8SPIInstance1, const uint8_t cu8SPIInstance2, const uint8_t cu8CSToCG147, uint8_t *pu8Cmd, uint8_t *pu8Value, uint16_t *pu16Response, uint8_t u8Size, uint32_t *pu32RequestTime)
 Schedules a series of 17-bit command transfers where the command is 7-bits long with a pre-calculated parity bit, arguments for the command are 8-bit long, and an extra parity bit for the complete message is added. This function requires the use of scheduled transfers.
void vfnCG147SyncPulse (const uint8_t cu8NSyncPort, const uint8_t cu8NSyncPin)
 Sends a Sync pulse using the N_SYNC pin. Delay is 40 usec.
uint8_t u8fnCG147WatchDogStartUp (void)
 Configures the first words to be sent to the SBC.
uint8_t u8fnCG147WatchDogNextWord (const uint8_t u8WordFromSBC)
 Calculates the next watchdog word based on the current response from the SBC.
void vfnCG147ComposeFrame (uint8_t *pu8Cmd, uint8_t *pu8Value, uint16_t *pu16ComposedMessage, uint8_t u8Size)
 This function mashes up a CG147 instruction with its argument into a 16-bit word. No parity is calculated.
uint16_t u16fnCG147ExtractScheduledPSI5Accel (const uint32_t *pu32RawResponse, uint16_t *pu16Accel, const uint16_t u16ChannelsMask)
 This fn can be called after executing a call to u8fnCG147ScheduleSafePSI5Accel in order to extract acceleration data from all PSI5 devices. It is built upon u8fnCG147ExtractPSIAccel and u8fnCG147ExtractResponse, and has a direct link to the contents of cau8ReadPSISensorsCmd.
uint8_t u8fnCG147ExtractPSIAccel (const uint32_t *pu32RawResponse, uint16_t *pu16Accel)
 Extracts acceleration data from a raw CG147 response. It also returns the status flags as sent by the device.
uint8_t u8fnCG147ExtractResponse (const uint32_t *pu32RawResponse, uint8_t *pu8Response)
 Extracts a non-acceleration response from the CG147, and formats it into an 8-bit response. It also returns the status flags as sent by the device.
uint16_t u16fn10BitOffsetFilter (uint16_t u16RawValue)
 This function performs a mathematical operation in order to turn incoming 10-bit signed acceleration data into 10-bit unsigned values with a half-scale offset. it also filters out any status bits that may come associated to the raw value.
void vfnCG147WD2Isr (void)
 Software Isr to be called by scheduler. It is used to schedule the next word to be sent to the SBC. In its current form, it also keeps a count used to calculate when to send the WD3 word.
void vfnReScheduleWD (void)
 Isr when rescheduling has been requested. Tries to write WD2 to the outbox. If it fails, it will reschedule again.
void vfnReScheduleWD3 (void)
 Isr when rescheduling has been requested. Tries to write WD3 to the outbox. If it fails, it will reschedule again.

Variables

const uint16_t cau16CG147InitCmdsArgs []
const uint8_t cu8CG147InitCmdsArgsSize
const uint8_t cau8CG147InitCmdsIn16Bit []
const uint8_t cau8CG147InitArgsIn16Bit []
uint16_t gau16CG147Responses [CG147_INPUT_BUFFER_SIZE]
uint8_t gau8CG147DSPIComplexInstances []
uint8_t gu8CG147WatchDog2ResponseFromMCU
uint8_t gu8CG147WatchDog3ResponseFromMCU
uint32_t gu32CG147WatchDog2RequestToMCU
uint32_t gu32CG147WatchDog3RequestToMCU
uint16_t gu16CG147WatchDog2IsrCount
uint16_t gu16CG147WatchDog3IsrCount

Detailed Description

Bosch's CG147 driver using proprietary mail scheduler and MPC5604P.

Copyright (c) 2011 Freescale Semiconductor Freescale Confidential Proprietary

Author:
Freescale Semiconductor
SASD Automotive
R11515
Version:
Date:
Warning:
(If needed)

History:


Define Documentation

#define CG147_PULSE_DELAY_20_USEC
Value:
(PIT_1_SEC / CG147_TIME_DIVIDER), \
                                      (uint16_t)(0.00002 * CG147_TIME_DIVIDER)
#define CG147_PULSE_DELAY_40_USEC
Value:
(PIT_1_SEC / CG147_TIME_DIVIDER), \
                                      (uint16_t)(0.00004 * CG147_TIME_DIVIDER)
#define CG147_TEST_CMD_SIZE_SECOND_PART
Value:
(N_ELEMENTS(cau8CG147TestCmds) \
                                         - CG147_TEST_CMD_SIZE_FIRST_PART)

Function Documentation

uint16_t u16fn10BitOffsetFilter ( uint16_t  u16RawValue)

This function performs a mathematical operation in order to turn incoming 10-bit signed acceleration data into 10-bit unsigned values with a half-scale offset. it also filters out any status bits that may come associated to the raw value.

Parameters:
u16RawValue,:Accel value as returned by the SBC
Returns:
u16AccelValue: Formated 10-bit unsigned accel value.
uint16_t u16fnCG147ExtractScheduledPSI5Accel ( const uint32_t *  pu32RawResponse,
uint16_t *  pu16Accel,
const uint16_t  u16ChannelsMask 
)

This fn can be called after executing a call to u8fnCG147ScheduleSafePSI5Accel in order to extract acceleration data from all PSI5 devices. It is built upon u8fnCG147ExtractPSIAccel and u8fnCG147ExtractResponse, and has a direct link to the contents of cau8ReadPSISensorsCmd.

Parameters:
pu32RawResponse,:32-bit complex response from device. In this format, the first 8-bits are placed in the MSW, right justified, and the second 9-bits are placed in the LSW, right justified.
pu16Response,:Pointer to where the acceleration measurements should be stored.
Returns:
CLEAR if all acceleration results were extracted correctly and their corresponding status was clear (refer to u8fnCG147ExtractPSIAccel); or a flag set for each channel that was not clear, from BIT0 to BIT11.
uint8_t u8fnCG147BatchTranscieve ( uint8_t *  pu8Cmd,
uint8_t *  pu8Value,
uint8_t  u8SPIInstance,
uint8_t  u8CSToCG147,
uint8_t  u8NOfMessages 
)

Sends a series of 7-bit commands with an 8-bit arguments to a CG147 SBC using SPI. Command parity should be pre-calculated. Response is placed in global variable gau16CG147Responses.

Parameters:
pu8Cmd,:pointer to an array of 7-bit commands with pre- calculated parity to be used.
pu8Value,:pointer to an array of 8-bit argument for the given commands.
u8SPIInstance,:SPI module and settings memory to be used. The SBC must be physically connected to this SPI, and the config must also be already loaded in the given memory port.
u8CSToCG147,:Mask for CS pin to be used.
u8NOfMessages,:Number of messages to be sent (size of arrays).
Returns:
u8Status: Zero if no problems found; DSPI_BUSY_WITH_PREVIOUS_TX if the HW is busy and cannot transmit existing data.
Warning:
Functional with Direct SPI Tx ONLY
uint8_t u8fnCG147ExtractPSIAccel ( const uint32_t *  pu32RawResponse,
uint16_t *  pu16Accel 
)

Extracts acceleration data from a raw CG147 response. It also returns the status flags as sent by the device.

Parameters:
pu32RawResponse,:32-bit complex response from device. In this format, the first 8-bits are placed in the MSW, right justified, and the second 9-bits are placed in the LSW, right justified.
pu16Response,:Pointer to where the extracted acceleration value shall be placed.
Returns:
Status byte as sent from the device via SPI:
  • zero if no status bits are set,
  • BIT0 if parity is incorrect
  • BIT2 if watch-dog flag is set
  • BIT3 if CG147 is busy with other request
  • BIT6 if device is in test mode
  • BIT7 if Transfer Failure Flag is set.
uint8_t u8fnCG147ExtractResponse ( const uint32_t *  pu32RawResponse,
uint8_t *  pu8Response 
)

Extracts a non-acceleration response from the CG147, and formats it into an 8-bit response. It also returns the status flags as sent by the device.

Parameters:
pu32RawResponse,:32-bit complex response from device. In this format, the first 8-bits are placed in the MSW, right justified, and the second 9-bits are placed in the LSW, right justified.
pu8Response,:Pointer to where the extracted response shall be placed.
Returns:
Status byte as sent from the device via SPI:
  • zero if no status bits are set,
  • BIT0 if parity is incorrect
  • BIT2 if watch-dog flag is set
  • BIT3 if CG147 is busy with other request
  • BIT6 if device is in test mode
  • BIT7 if Transfer Failure Flag is set.
uint8_t u8fnCG147ReadAOut ( const uint8_t  cu8DSPIInstance,
const uint8_t  cu8ChipSelect,
const uint8_t  cu8ADCInstance,
const uint8_t  cu8ADCCh,
const uint8_t  cu8CG147Ch,
uint16_t *  pu16Result 
)

Configures CG147 for a particular AOUT value, configures the MCU for reading this channel and launches a "normal" acquisition.

Parameters:
cu8DSPIInstance,:SPI instance to which the SBC is associated.
cu8ChipSelect,:Chip Select mask to which the SBC is associated.
cu8ADCInstance,:ADC instance to be used.
cu8ADCCh,:ADC channel to which the measurement is connected.
cu8CGG147,:CG147's AOUT channel.
pu16Result,:Address of where the result will be stored.
Returns:
Clear if no problems found; ADC_ERR_ONGOING_CONV if there's an on-going request when triggered; DSPI_BUSY_WITH_PREVIOUS_TX if the HW is busy and cannot transmit existing data.
Warning:
Functional with Direct SPI Tx ONLY
This function is not compatible with the current ADC architecture. It shall be deprecated or modified. DO NOT USE.
uint8_t u8fnCG147ReadPSI5Accel ( const uint8_t  cu8DSPIInstance,
const uint8_t  cu8ChipSelect,
uint16_t *  pu16Accel 
)

Asks the SBC for PSI acceleration values. This fn. automatically converts signed data into unsigned data.

Parameters:
cu8DSPIInstance,:SPI instance to which the SBC is associated.
cu8ChipSelect,:Chip Select mask to which the SBC is associated.
pu16Accel,:Pointer to a 4-word array (8-byte) to which the accel value should be stored.
Returns:
u8Status: Zero if no problems found; DSPI_BUSY_WITH_PREVIOUS_TX if the HW is busy and cannot transmit existing data.
Warning:
Functional with Direct SPI Tx ONLY
This function is hard-coded for 4 satellites.
uint8_t u8fnCG147ReadPSI5RegSensor ( const uint8_t  cu8DSPIInstance,
const uint8_t  cu8ChipSelect,
uint16_t *  pu16Accel 
)

Asks the SBC for PSI acceleration values. This fn does not convert signed data into unsigned data.

Parameters:
cu8DSPIInstance,:SPI instance to which the SBC is associated.
cu8ChipSelect,:Chip Select mask to which the SBC is associated.
pu16Accel,:Pointer to a 4-word array (8-byte) to which the accel value should be stored.
Returns:
u8Status: Zero if no problems found; DSPI_BUSY_WITH_PREVIOUS_TX if the HW is busy and cannot transmit existing data.
Warning:
Functional with Direct SPI Tx ONLY
This function is hard-coded for 4 satellites.
uint8_t u8fnCG147ScheduleAOut ( const uint8_t  cu8DSPIInstance,
const uint8_t  cu8ChipSelect,
const uint8_t  cu8CG147Ch,
uint16_t *  pu16Status,
uint32_t *  pu32Time 
)

Schedules a CG147 configuration for a particular AOUT value. This function assumes that the ADC is always running and that the correct pin connected to AOut has been scheduled for reading.

Parameters:
cu8DSPIInstance,:SPI instance to which the SBC is associated.
cu8ChipSelect,:Chip Select mask to which the SBC is associated.
cu8CG147Ch,:CG147's AOUT channel (refer to defines above).
pu16Status,:Pointer to the SPI response coming from this command. Result is one 16-bit word long.
pu32Time,:Time stamp from the scheduler.
Returns:
Zero if no problems, otherwise MAILBOX_IS_BEING_WRITTEN, or MAILBOX_CAPACITY_HAS_BEEN_REACHED.
Warning:
Functional with 16-bit scheduled transfers only.
uint8_t u8fnCG147ScheduleBatchTransfer ( uint8_t  u8SPIInstance,
uint8_t  u8CSToCG147,
uint8_t *  pu8Cmd,
uint8_t *  pu8Value,
uint16_t *  pu16Response,
uint8_t  u8Size,
uint32_t *  pu32RequestTime 
)

Schedules a series of 7-bit commands with an 8-bit arguments to a CG147 SBC using SPI. Command parity should be pre-calculated.

Parameters:
u8SPIInstance,:SPI module and settings memory to be used. The SBC must be physically connected to this SPI, and the config must also be already loaded in the given memory port.
u8CSToCG147,:Mask for CS pin to be used.
pu8Cmd,:pointer to an array of 7-bit commands with pre- calculated parity to be used.
pu8Value,:pointer to an array of 8-bit argument for the given commands.
pu16Response,:Pointer to location where the response will be stored
pu32RequestTime,:Pointer to a 32-bit variable where the current execution cycle from the scheduler is stored.
u8NOfMessages,:Number of messages to be sent (size of arrays).
Returns:
Zero if no problems, otherwise MAILBOX_IS_BEING_WRITTEN, or MAILBOX_CAPACITY_HAS_BEEN_REACHED.
Warning:
Functional with 16-bit scheduled transfers only.
uint8_t u8fnCG147SchedulePSI5Accel ( const uint8_t  cu8DSPIInstance,
const uint8_t  cu8ChipSelect,
uint16_t *  pu16Accel,
uint32_t *  pu32Time 
)

Schedules a request for PSI acceleration values. This fn does not convert signed data into unsigned data.

Parameters:
cu8DSPIInstance,:SPI instance to which the SBC is associated.
cu8ChipSelect,:Chip Select mask to which the SBC is associated.
pu16Accel,:Pointer to a 4-word array (8-byte) to which the accel value should be stored.
pu32Time,:Time stamp from the scheduler.
Returns:
Zero if no problems, otherwise MAILBOX_IS_BEING_WRITTEN, or MAILBOX_CAPACITY_HAS_BEEN_REACHED.
Warning:
Functional with 16-bit scheduled transfers only.
uint8_t u8fnCG147ScheduleSafeAOut ( const uint8_t  cu8DSPIInstance1,
const uint8_t  cu8DSPIInstance2,
const uint8_t  cu8ChipSelect,
const uint8_t  cu8CG147Ch,
uint32_t *  pu32Status,
uint32_t *  pu32Time 
)

Schedules a CG147 configuration for a particular AOUT value. Assumes configuration for ADC on micro's side is set.

Parameters:
cu8DSPIInstance1,:SPI instance to which the first half of the transfer is associated.
cu8DSPIInstance2,:SPI instance to which the second half of the transfer is associated.
cu8ChipSelect,:Chip Select mask to which the SBC is associated.
cu8CG147Ch,:CG147's AOUT channel (refer to defines above).
pu16Status,:Pointer to the SPI response coming from this command. Result is one 16-bit word long.
pu32Time,:Time stamp from the scheduler.
Returns:
Zero if no problems, otherwise MAILBOX_IS_BEING_WRITTEN, or MAILBOX_CAPACITY_HAS_BEEN_REACHED.
Warning:
Functional with 17-bit scheduled transfers only.
uint8_t u8fnCG147ScheduleSafeBatchTransfer ( const uint8_t  cu8SPIInstance1,
const uint8_t  cu8SPIInstance2,
const uint8_t  cu8CSToCG147,
uint8_t *  pu8Cmd,
uint8_t *  pu8Value,
uint16_t *  pu16Response,
uint8_t  u8Size,
uint32_t *  pu32RequestTime 
)

Schedules a series of 17-bit command transfers where the command is 7-bits long with a pre-calculated parity bit, arguments for the command are 8-bit long, and an extra parity bit for the complete message is added. This function requires the use of scheduled transfers.

Parameters:
u8SPIInstance1,:SPI module and settings memory to be used for the first half of the transfer. The SBC must be physically connected to this SPI, and the config must also be already loaded in the given memory port.
u8SPIInstance2,:SPI module and settings memory to be used for the second half of the transfer. The SBC must be physically connected to this SPI, and the config must also be already loaded in the given memory port.
u8CSToCG147,:Mask for CS pin to be used.
pu8Cmd,:pointer to an array of 7-bit commands with pre- calculated parity to be used.
pu8Value,:pointer to an array of 8-bit argument for the given commands.
pu16Response,:Pointer to location where the response will be stored. Each response will require 2 16-bit locations, where the MSW will contain the status byte response, and the LSW will contain the device's response plus a parity bit. Everything will be right-justified.
u8Size,:Number of Cmd+Value elements that shall be sent. This will also determine the size of the array needed for the response (essentially [2 * u8Size]).
pu32RequestTime,:Pointer to a 32-bit variable where the current execution cycle from the scheduler is stored.
Returns:
Zero if no problems, otherwise MAILBOX_IS_BEING_WRITTEN, or MAILBOX_CAPACITY_HAS_BEEN_REACHED
Warning:
Functional with 17-bit scheduled transfers only.
uint8_t u8fnCG147ScheduleSafePSI5Accel ( const uint8_t  cu8DSPIInstance1,
const uint8_t  cu8DSPIInstance2,
const uint8_t  cu8ChipSelect,
const uint16_t  cu16ActiveChannels,
uint32_t *  pu32RawAccel,
uint32_t *  pu32Time 
)

Schedules a request for PSI acceleration values. This fn does not convert signed data into unsigned data.

Parameters:
cu8DSPIInstance1,:SPI instance to which the first half of the transfer is associated.
cu8DSPIInstance2,:SPI instance to which the second half of the transfer is associated.
cu8ChipSelect,:Chip Select mask to which the SBC is associated.
cu16ActiveChannels,:Mask with active satellites as 1's, inactive (or disabled) ones as 0.
pu32RawAccel,:Pointer to a 4-word array (16-byte) to which the accel value (as a raw response from the device) should be stored.
pu32Time,:Time stamp from the scheduler.
Returns:
Zero if no problems, otherwise MAILBOX_IS_BEING_WRITTEN, or MAILBOX_CAPACITY_HAS_BEEN_REACHED.
Warning:
Functional with 17-bit scheduled transfers only.
uint8_t u8fnCG147ScheduleSafeSquibFireStart ( const uint8_t  cu8DSPIInstance1,
const uint8_t  cu8DSPIInstance2,
const uint8_t  cu8ChipSelect,
uint16_t  u16ChannelMask,
uint32_t *  pu32Time 
)

This fn. shall be called when the decision to deploy an airbag has been taken. It will bring FL_EN high, enable the high-side and low-side switches.

Parameters:
cu8DSPIInstance1,:SPI instance to which the SBC is associated. (first half)
cu8DSPIInstance1,:SPI instance to which the SBC is associated. (second half)
cu8ChipSelect,:Chip Select mask to which the SBC is associated.
u16ChannelMask,:Mask used to trigger each airbag. LSB = Ch0, BIT11 = CH11.
pu32Time,:Time stamp from the scheduler.
Returns:
Zero if no problems, otherwise MAILBOX_IS_BEING_WRITTEN, or MAILBOX_CAPACITY_HAS_BEEN_REACHED.
Warning:
Functional with 17-bit scheduled transfers only.
uint8_t u8fnCG147ScheduleSafeSquibFireStop ( const uint8_t  cu8DSPIInstance1,
const uint8_t  cu8DSPIInstance2,
const uint8_t  cu8ChipSelect,
uint32_t *  pu32Time 
)

This fn. shall be called after an airbag has been deployed to disable low-side and high-side drivers.

Parameters:
cu8DSPIInstance1,:SPI instance to which the SBC is associated. (first half)
cu8DSPIInstance1,:SPI instance to which the SBC is associated. (second half)
cu8ChipSelect,:Chip Select mask to which the SBC is associated.
pu32Time,:Time stamp from the scheduler.
Returns:
Zero if no problems, otherwise MAILBOX_IS_BEING_WRITTEN, or MAILBOX_CAPACITY_HAS_BEEN_REACHED.
Warning:
Functional with 17-bit scheduled transfers only.
uint8_t u8fnCG147ScheduleSafeTest ( const uint8_t  cu8DSPIInstance1,
const uint8_t  cu8DSPIInstance2,
const uint8_t  cu8ChipSelect,
uint8_t  u8TestCase,
uint32_t *  pu32Result,
uint16_t *  pu16ADCResponses,
uint32_t *  pu32Time 
)

This fn. is meant to execute one of the three capacitor tests described in the CG147 spec using cau8CG147TestCmds as commands. It is called by upper-layer routines as required. Final result is not the status of the test.

Parameters:
cu8DSPIInstance1,:SPI instance to which the SBC is associated. (first half)
cu8DSPIInstance1,:SPI instance to which the SBC is associated. (second half)
cu8ChipSelect,:Chip Select mask to which the SBC is associated.
u8TestCase,:This is the value that will be passed to SBC_POWER_CTRL to perform the actual test. Valid values are CG147_TEST_IS_VER_ESR, CG147_TEST_IS_VER_CAP, and CG147_TEST_IS_POL_PROT. No check is performed to verify the validity of the passed value.
pu32Result,:location of array of elements where the result will be stored in raw fashion. Declared as a 32-bit element instead of a 16-bit element since result will require 2 16-bit elements anyway.
pu16ADCResponses,:Pointer to location where an ADC readings will be placed. These particular value are a series of voltage levels seen in the AOUT pin as the test takes place. An array with CG147_N_ADC_DATA elements is required.
pu32Time,:Time stamp from the scheduler.
Returns:
Zero if no problems, otherwise MAILBOX_IS_BEING_WRITTEN, or MAILBOX_CAPACITY_HAS_BEEN_REACHED.
Warning:
Functional with 17-bit scheduled transfers only.
uint8_t u8fnCG147ScheduleSafeTransfer ( const uint8_t  cu8SPIInstance1,
const uint8_t  cu8SPIInstance2,
const uint8_t  cu8CSToCG147,
uint8_t  u8Cmd,
uint8_t  u8Value,
uint16_t *  pu16Response,
uint32_t *  pu32RequestTime 
)

Schedules ONE 17-bit command transfers where the command is 7-bits long with a pre-calculated parity bit, arguments for the command are 8-bit long, and an extra parity bit for the complete message is added. This function requires the use of scheduled transfers.

Parameters:
u8Cmd,:7-bit command to be used, with pre-calculated parity.
u8Value,:8-bit argument for the given command.
u8SPIInstance1,:SPI module and settings memory to be used for the first half of the transfer. The SBC must be physically connected to this SPI, and the config must also be already loaded in the given memory port.
u8SPIInstance2,:SPI module and settings memory to be used for the second half of the transfer. The SBC must be physically connected to this SPI, and the config must also be already loaded in the given memory port.
u8CSToCG147,:Mask for CS pin to be used.
pu16Response,:Pointer to location where the response will be stored. It will require 2 16-bit locations, where the MSW will contain the status byte response, and the LSW will contain the device's response plus a parity bit. Everything will be right-justified.
pu32RequestTime,:Pointer to a 32-bit variable where the current execution cycle from the scheduler is stored.
Returns:
Zero if no problems, otherwise MAILBOX_IS_BEING_WRITTEN, or MAILBOX_CAPACITY_HAS_BEEN_REACHED
Warning:
Functional with 17-bit scheduled transfers only.
uint8_t u8fnCG147ScheduleTransfer ( uint8_t  u8SPIInstance,
uint8_t  u8CSToCG147,
uint8_t  u8Cmd,
uint8_t  u8Value,
uint16_t *  pu16Response,
uint32_t *  pu32RequestTime 
)

Schedules a 7-bit command with an 8-bit argument to a CG147 SBC using SPI & the scheduler. Command parity should be pre-calculated.

Parameters:
u8SPIInstance,:SPI module and settings memory to be used. The SBC must be physically connected to this SPI, and the config must also be already loaded in the given memory port
u8CSToCG147,:Mask for CS pin to be used.
u8Cmd,:7-bit command to be used, with pre-calculated parity.
u8Value,:8-bit argument for the given command.
pu16Response,:Pointer to location where the response will be stored
pu32RequestTime,:Pointer to a 32-bit variable where the current execution cycle from the scheduler is stored.
Returns:
Zero if no problems, otherwise MAILBOX_IS_BEING_WRITTEN, or MAILBOX_CAPACITY_HAS_BEEN_REACHED.
Warning:
Functional with 16-bit scheduled transfers only.
vuint8_t u8fnCG147Transcieve ( uint8_t  u8Cmd,
uint8_t  u8Value,
uint8_t  u8SPIInstance,
uint8_t  u8CSToCG147 
)

Sends a 7-bit command with an 8-bit argument to a CG147 SBC using SPI. Command parity should be pre-calculated. Response is placed in global variable gau16CG147Responses.

Parameters:
u8Cmd,:7-bit command to be used, with pre-calculated parity.
u8Value,:8-bit argument for the given command.
u8SPIInstance,:SPI module and settings memory to be used. The SBC must be physically connected to this SPI, and the config must also be already loaded in the given memory port.
u8CSToCG147,:Mask for CS pin to be used.
Returns:
u8Status: Zero if no problems found; DSPI_BUSY_WITH_PREVIOUS_TX if the HW is busy and cannot transmit existing data.
Warning:
Functional with Direct SPI Tx ONLY
uint8_t u8fnCG147WatchDogNextWord ( const uint8_t  u8WordFromSBC)

Calculates the next watchdog word based on the current response from the SBC.

Parameters:
u8WordFromSBC,:Latest response from SBC
Returns:
Next word to be sent to the SBC's watchdog.
uint8_t u8fnCG147WatchDogStartUp ( void  )

Configures the first words to be sent to the SBC.

Parameters:
None
Returns:
Always CLEAR.
void vfnCG147ComposeFrame ( uint8_t *  pu8Cmd,
uint8_t *  pu8Value,
uint16_t *  pu16ComposedMessage,
uint8_t  u8Size 
)

This function mashes up a CG147 instruction with its argument into a 16-bit word. No parity is calculated.

Parameters:
pu8Cmd,:pointer to an array of 7-bit+parity commands to be used.
pu8Value,:pointer to an array of 8-bit argument for the given commands.
pu16ComposedMessage,:Pointer to array to contain the resulting 16-bit message with command parity.
u8Size,:Number of messages to process.
Returns:
void.
void vfnCG147Init ( const uint8_t  cu8DSPIMainInstance,
const uint8_t  cu8ChipSelect,
const uint8_t  cu8DSPISecondaryInstance1,
const uint8_t  cu8DSPISecondaryInstance2,
const uint8_t  cu8NSysResPort,
const uint8_t  cu8NSysResPin 
)

Initializes the SBC based on pre-configured table.

Parameters:
cu8DSPIMainInstance,:SPI instance to which the SBC is associated when performing 16-bit transfers
cu8DSPISecondaryInstance1,:SPI instance to which the SBC is associated when performing 17-bit transfers.
cu8DSPISecondaryInstance2,:SPI instance to which the SBC is associated when performing 17-bit transfers.
cu8ChipSelect,:Chip Select mask to which the SBC is associated.
cu8NSysResPort,:Port to which the N_SYS_RES pin belongs.
cu8NSysResPin,:Pin in port to which N_SYS_RES is associated.
Returns:
Void.
Warning:
Functional with Direct SPI Tx in 16-bits ONLY
void vfnCG147SyncPulse ( const uint8_t  cu8NSyncPort,
const uint8_t  cu8NSyncPin 
)

Sends a Sync pulse using the N_SYNC pin. Delay is 40 usec.

Parameters:
cu8NSyncPort,:Port to which the N_SYNC pin belongs.
cu8NSyncPin,:Pin associated to the N_SYNC function.
Returns:
void
void vfnCG147ToggleResetPin ( const uint8_t  cu8State,
const uint8_t  cu8NSysResPort,
const uint8_t  cu8NSysResPin 
)

Sets a logical level on the SBC's reset pin.

Parameters:
cu8State,:TRUE if the pin shall hold a high logical level; CLEAR otherwise.
cu8NSysResPort,:Port to which the N_SYS_RES pin belongs.
cu8NSysResPin,:Pin in port to which N_SYS_RES is associated.
Returns:
Void.
void vfnCG147WD2Isr ( void  )

Software Isr to be called by scheduler. It is used to schedule the next word to be sent to the SBC. In its current form, it also keeps a count used to calculate when to send the WD3 word.

Parameters:
None
Returns:
Void
void vfnReScheduleWD ( void  )

Isr when rescheduling has been requested. Tries to write WD2 to the outbox. If it fails, it will reschedule again.

Parameters:
None
Returns:
Void
void vfnReScheduleWD3 ( void  )

Isr when rescheduling has been requested. Tries to write WD3 to the outbox. If it fails, it will reschedule again.

Parameters:
None
Returns:
Void

Variable Documentation

Remembers the 2 CTARs used to create complex (17-bit) transfers

Used to count how many ISRs must occur before sending a WD2 response

Used to count how many ISRs must occur before sending a WD3 response

Contains CG147's request for a WD2

Contains CG147's request for a WD3

Contains response from MCU to CG147 regarding WD2

Contains response from MCU to CG147 regarding WD3